<?php
/**
 * Created by PhpStorm.
 * User: XYX
 * Date: 2017/8/25
 * Time: 10:45
 */

namespace App\Transform;


use App\Consumer;
use App\Twitter;

class TwitterCommentTransform extends Transformer
{
    protected $picTransform;
    protected $commentsTranform;
    public function __construct(TwitterPicTransform $picTransform,TwitterCommentsTransform $commentsTranform)
    {
        $this->picTransform = $picTransform;
        $this->commentsTranform = $commentsTranform;
    }

    public function transFrom($item)
    {

        // TODO: Implement transFrom() method.
        return
        [
            'id'=>$item['id'],
            'body'=>'#'.$item['clubname'].'#'.$item['content'],
            'username'=>Consumer::findOrFail($item['consumer_id'])->nickname,
            'twitterpic'=>$this->picTransform->transformCollect(Twitter::findOrFail($item['id'])->twitterpics),
            'twittercomment'=>$this->commentsTranform->transformCollect(Twitter::findOrFail($item['id'])->comments),
        ];

    }
}